package com.hfzy.ihk.web.linkcall.controller;

import com.hfzy.ihk.common.web.WebResult;
import com.hfzy.ihk.web.linkcall.biz.TestEntityBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.client.OAuth2RestOperations;
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Administrator on 2018/7/18.
 *
 * @author wws
 */
@RequestMapping("my")
@RestController
public class TestController {

    @Autowired
    TestEntityBiz testBiz;

//    @Autowired
//    OAuth2RestOperations restOperations;

//    @Autowired
//    OAuth2RestTemplate oAuth2RestTemplate;
    @GetMapping("api1/hi")
    public String getStr(){
//        String personResourceUrl = "http://10.10.37.142:8888/userCenter/my/api1/test";
////    mav.addObject("person",
////            restOperations.getForObject(personResourceUrl, String.class));
//        System.out.println("token:"+oAuth2RestTemplate.getAccessToken());
//        String rs = oAuth2RestTemplate.getForObject(personResourceUrl,String.class);
        return "hello";
    }

    @RequestMapping("save")
    public WebResult save(){

        return testBiz.saveTestEntity();
    }


    @RequestMapping("/api/test")
    public String test(){
        //获取权限看看
//        OAuth2Authentication authentication = (OAuth2Authentication) SecurityContextHolder.getContext().getAuthentication();

        return "成功";
    }
}
